﻿using System;

namespace AppToolkit.WPF.ComponentModel
{
    /// <summary>
    /// Interface that signalles that the component supports change notification.
    /// </summary>
    /// <typeparam name="TItem">The type of the item.</typeparam>
    public interface IItemChangedSupport<TItem>
    {
        /// <summary>
        /// Occurs when [item changed].
        /// </summary>
        event EventHandler<ItemChangedEventArgs<TItem>> ItemChanged;
    }

    /// <summary>
    /// Implementation of the ItemChangedEventArgs.
    /// </summary>
    /// <typeparam name="TItem">The type of the item.</typeparam>
    public class ItemChangedEventArgs<TItem> : EventArgs
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemChangedEventArgs&lt;TItem&gt;"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="propertyName">Name of the property.</param>
        public ItemChangedEventArgs(TItem item, string propertyName)
        {
            this.Item = item;
            this.PropertyName = propertyName;
        }

        /// <summary>
        /// Gets the changed item.
        /// </summary>
        public TItem Item { get; private set; }

        /// <summary>
        /// Gets the name of the property.
        /// </summary>
        /// <value>
        /// The name of the property that has changed.
        /// </value>
        public string PropertyName { get; private set; }
    }
}